package demo1;

import java.io.FileNotFoundException;
import java.io.IOException;

class A{
   public void func() throws IOException{

    }
}

class B extends A{
    public void func()throws IOException {

    }
}
public class Login {
    public String name = "root";
    public String password = "123456@";

    /*public void login(String name, String password) throws UserErrorException,PasswordErrorException {
        if(!this.name.equals(name)){
            throw new UserErrorException("用户名错误"+ name);
        }

        if(!this.password.equals(password)){
            throw new PasswordErrorException("密码错误"+ password);
        }


    }

    public static void main(String[] args) {

        try {
            Login l = new Login();
            l.login("root", "123456@");
        }catch (UserErrorException e){
            e.printStackTrace();
        }catch (PasswordErrorException e){
            e.printStackTrace();
        }

        System.out.println("程序继续执行...");
    }*/

    public void login(String name, String password){
        try {
            if(!this.name.equals(name)){
                throw new UserErrorException("用户名错误,发生了异常..."+ name);
            }

            if(!this.password.equals(password)){
                throw new PasswordErrorException("密码错误,发生了异常..."+ password);
            }
        }catch (UserErrorException e){
            e.printStackTrace();

        }catch (PasswordErrorException e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Login login = new Login();
        login.login("root", "123456@");
        System.out.println("程序继续执行...");

        System.out.println(func());
    }

    public static int func(){
        try {
            int[] array = null;
            System.out.println(array.length);
            return 10;
        }catch (NullPointerException e){
            e.printStackTrace();
            return 20;
        }finally {
            return 30;
        }

    }
}
